package TomcatStudy;

import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

/*
*模拟tomcat运行
* 客户端类
 */
public class Client {

    private static int port = 30000;
    private static String host = "127.0.0.1";

    public static void main(String[] args) throws IOException {
        /*try {
            Socket con = new Socket(host,port);
            System.out.println("请输入URL地址");
            Scanner scanner = new Scanner(System.in);
            String info =  scanner.nextLine().trim();
            Writer writer = new OutputStreamWriter(con.getOutputStream());
            writer.write(info);
            writer.flush();

        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }*/
        Socket socket = new Socket(host, port);
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line = bufferedReader.readLine();
        System.out.println("来自服务器的数据： " + line);
        bufferedReader.close();
        socket.close();

    }
}
